--
-- Description: script to create the Events table.
-- Date created: 17 Apr 2008
--

set ANSI_NULLS on
set QUOTED_IDENTIFIER on
go

if not exists 
(
    select * 
    from dbo.sysobjects
    where id = object_id(N'[dbo].[Events]')
    and objectproperty(id, N'IsUserTable') = 1
)
begin
    create table [dbo].[Events]
    (
        [EventID] bigint not null
        , [EventTypeID] smallint not null
        , [DateCreated] smalldatetime not null
        , [DateModified] smalldatetime not null
        , [TotalHits] bigint not null
        , [ApplicationName] nvarchar(400) not null
        , [ApplicationVersion] varchar(24) not null
        , [ApplicationStampDate] datetime null
        , [ModuleName] nvarchar(400) not null
        , [ModuleVersion] varchar(24) not null
        , [ModuleStampDate] datetime null
        , [Offset] nvarchar(50) not null
        , [ExceptionCode] char(10) null
        constraint [PK_Events] primary key clustered
        (
            [EventID] asc
            , [EventTypeID] asc
        ) on [primary]
    ) on [primary]

    print ''
    print '*************************************************************************************'  
    print 'Created table [dbo].[Events]'
    print '*************************************************************************************'  
    print ''
end
else
begin
    print ''
    print '*************************************************************************************'  
    print 'Table [dbo].[Events] already exists.'
    print '*************************************************************************************'  
    print ''
end
